package com.autcar.training.service;

import com.autcar.training.dao.InsuranceMapper;
import com.autcar.training.entity.Insurance;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Create by linjh on 9/2
 */

/***
 * 保险模块服务
 */
@Service
public class InsuranceServiceImpl implements InsuranceService {

    @Resource
    private InsuranceMapper insuranceMapper;

    @Override
    public Integer addInsurance(Insurance insurance) {

        return insuranceMapper.insert(insurance);
    }

    @Override
    public Integer deleteInsurance(Integer id) {
        return insuranceMapper.deleteById(id);
    }

    @Override
    public List<Insurance> findById(Integer oid) {
        QueryWrapper<Insurance> wrapper = new QueryWrapper<>();
        wrapper.eq("oid",oid);
        Insurance insurance=insuranceMapper.selectOne(wrapper);
        List<Insurance> list=new ArrayList<>();
        list.add(insurance);
        return list;
    }

    @Override
    public List<Insurance> findAll() {
        return insuranceMapper.selectList(null);
    }

    @Override
    public Integer EditOne(Insurance insurance) {
        return insuranceMapper.updateById(insurance);
    }
}
